DECLARE @g geometry;

declare @gg as varbinary(MAX)

declare @ggg as varbinary(MAX)--geometry

declare @str as varchar(max)

declare @gdo as varbinary(MAX)


--set @str='POLYGON((0 0,0 10,10 10,10 0,0 0),(3 3,7 3,7 7,3 7, 3 3))'

set @str='MULTIPOLYGON(((3 3,3 10,10 10,10 3,3 3),(3 3,7 3,7 7,3 7, 3 3)),((15 15,15 25,25 25,25 15,15 15)))'

--SET @g = geometry::STGeomFromText('MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(3 3,7 3,7 7,3 7, 3 3)),((15 15,15 25,25 25,25 15,15 15)))',0)

SET @g = geometry::STGeomFromText(@str,0)

SELECT @g.STAsBinary()
union all
select dbo.GdoBlob2Wkb(dbo.Wkt2GdoBlob(@str));


select @g

set @gg = dbo.Wkb2GdoBlob(@g.STAsBinary())

set @gdo = dbo.Wkt2GdoBlob(@str)

set @ggg = dbo.GdoBlob2Wkb(@gg)

select case when @gg=@gdo then 1 else 0 end

select case when @ggg=@g.STAsBinary() then 1 else 0 end

select dbo.Wkb2GdoBlob(@g.STAsBinary())
